<template>
	<view class="search" :style="{
		'background':color ? color : 'none',
		'margin-bottom':bottom ? bottom : '28rpx'
	}" :class=" type ? '' :'searchhover'">
		<!-- #ifndef H5 -->
		<view class="head-nav"></view>
		<!-- #endif -->
		<view class="box">
			<!-- 搜索导航 -->
			<block v-if="type" >
				<text @click="backTo" class="back iconfont icon-fanhui"></text>
				<view class="search-input2">
					<text class="iconfont icon-sousuo"></text>
					<input type="text" v-model="text" placeholder-class="place-holderClass" placeholder="请输入任务标题/编号/关键字/昵称"/>
				</view>
				<text class="textSearch" @click="search">搜索</text>
			</block>
			<!-- 普通搜索导航 -->
			<block v-else>
				<view class="search-input" @click="!inputJudge ? $util.redirectTo('/pages/search/search') : ''">
					<text class="iconfont icon-sousuo"></text>
					<input type="text" placeholder="请输入任务标题/编号/关键字/昵称" v-model="text" v-if="inputJudge" @blur="blur">
					<text class="txt" v-else>请输入任务标题/编号/关键字/昵称</text>
				</view>
				<view class="ser-btn" v-if="inputJudge" @click="$emit('determine',{'name':text})">搜索</view>
				<text class="iconfont icon-xinxi" :style="{
					'color':color ? '#fff' : 'none'
				}" @click="$util.redirectTo('/pages/messagecenter/messagecenter')" v-else></text>
			</block>
		</view>
	</view>
</template>

<script>
	export default{
		props:{
			type:{
				type:Boolean,
				default:false
			},
			value:{
				type:String,
				default:''
			},
			color:{
				type:String,
				default:''
			},
			bottom:{
				type:String,
				default:''
			},
			inputJudge:{
				type:Boolean,
				default:false
			},
		},
		data(){
			return{
				text:''
			}
		},
		mounted() {
			this.text = this.value;
		},
		methods:{
			// 后退
			backTo(){
				uni.navigateBack({
					delta: 1
				});
			},
			//搜索
			search(){
				this.$util.redirectTo('/pages/tasklist/tasklist',{
					name:this.text
				});
			},
			blur(){
				this.$emit('blur',{'name':this.text})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.search{
		width: 100%;
		background: #FFFFFF;
		padding: 0 40rpx 20rpx 30rpx;
		box-sizing: border-box;
		margin-bottom:28rpx;
		.box{
			width: 100%;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding-top: 20rpx;
			.search-input{
				padding: 0 56rpx 0 70rpx;
				box-sizing: border-box;
				display: flex;
				align-items: center;
				width: 600rpx;
				height: 64rpx;
				border-radius: 64rpx;
				font-size: 26rpx;
				color: #CACED1;
				background: #EFF2F7;
				opacity: 1;
				margin-bottom: 20rpx;
				input{
					font-size:24rpx;
					width: 90%;
					color: #373737;
				}
				.iconfont{
					margin-right: 16rpx;
				}
			}
			.ser-btn{
				height: 64rpx;
				text-align: center;
				line-height: 64rpx;
				font-size: 24rpx;
				color: #FFFFFF;
				margin-bottom: 20rpx;
			}
			.icon-xinxi{
				font-size: 52rpx;
				color: #373737 ;
				margin-bottom: 20rpx;
			}
			.search-input2{
				padding: 0 22rpx 0 44rpx;
				box-sizing: border-box;
				display: flex;
				align-items: center;
				width: 560rpx;
				height: 64rpx;
				border-radius: 64rpx;
				background: #EFF2F7;
				font-family: PingFangSC-regular;
				input{
					width: 80%;
					font-size: 26rpx;
				}
				.iconfont{
					color: #CACED1;
					margin-right: 16rpx;
				}
			}
			.textSearch{
				color: $uni-tabbar-hovercolor;
				font-size: 28rpx;
				font-weight: bold;
			}
			.back{
				font-size: 40rpx;
				font-weight: bold;
			}
			.place-holderClass{
				font-size: 26rpx;
				opacity: .5;
				font-family: PingFangSC-regular;
			}
		}
		
	}
	.searchhover{
		padding: 0 30rpx;
		box-shadow: 0px 2px 6px 0px rgba(119, 119, 119, .2);
	}
	.head-nav{
		width: 100%;
		height: var(--status-bar-height);
		margin-top: 10rpx;
	}
</style>
